{% extends 'IcsocUIBundle::page.html.twig' %}
{% block content %}
    <div class="alert alert-{{ datavalue.type }}">
        <p id="redirectionMsg">
            {% if datavalue.auto_redirect %}
                如果您不做出选择，将在 <span id="spanSeconds" class="badge badge-pink">3</span> 秒后跳转到第一个链接地址。
            {% endif %}
        </p>
        <p>
            {{ datavalue.msg_detail }}
        </p>
        <p>
            {% for link in datavalue.link %}
                <a class="btn btn-white btn-sm btn-primary" href="{{ link.href }}">
                    <i class="ace-icon fa fa-angle-double-right"></i> {{ link.text }}
                </a>
            {% endfor %}
        </p>
    </div>
{% endblock %}
{% block footer %}
        {% if datavalue.auto_redirect %}
        <script language="JavaScript">
            <!--
            var seconds = 3;
            var defaultUrl = "{{ datavalue.default_url }}";
            var intervalId = null;
            onload = function()
            {
                if (defaultUrl == 'javascript:history.go(-1)' && window.history.length == 0)
                {
                    document.getElementById('redirectionMsg').innerHTML = '';
                    return;
                }
                intervalId = window.setInterval(redirection, 1000);
            };
            function redirection()
            {
                if (seconds <= 0)
                {
                    window.clearInterval(intervalId);
                    return;
                }

                seconds--;
                document.getElementById('spanSeconds').innerHTML = seconds.toString();

                if (seconds == 0)
                {
                    window.clearInterval(intervalId);
                    location.href = defaultUrl;
                }
            }
        //-->
    </script>
    {% endif %}
{% endblock %}